package com.unionfind_01;

/**
 * @Author: tgy
 * @Date: 1/11/21 3:18 PM
 */
public abstract class AbstractUnionFind implements UnionFind{

    protected int[] parents;

    public AbstractUnionFind(int size) {

        parents = new int[size];

        for (int i = 0; i < size; i++) {

            parents[i] = i;
        }
    }

    @Override
    public boolean isSame(int v1, int v2) {

        return find(v1) == find(v2);
    }
}
